HAL SMBUS Types

HAL SMBUS Types

group SMBUS_Exported_Types

Typedefs

typedef struct hal_smbus_handle_s hal_smbus_handle_t

SMBUS handle structure type

typedef void ( * hal_smbus_cb_t ) ( hal_smbus_handle_t * hsmbus )

Pointer to an SMBUS callback function.

typedef void ( * hal_smbus_slave_addr_cb_t ) ( hal_smbus_handle_t * hsmbus , hal_smbus_slave_xfer_direction_t xfer_direction , uint32_t addr_match_code )

Pointer to an SMBUS slave address match callback function.

Enums

enum hal_smbus_t

HAL SMBUS instance.

Values:

enumerator HAL_SMBUS1

Peripheral instance I2C1

enumerator HAL_SMBUS2

Peripheral instance I2C2

enum hal_smbus_state_t

HAL state structure definition.

Values:

enumerator HAL_SMBUS_STATE_RESET

Not yet initialized

enumerator HAL_SMBUS_STATE_INIT

Initialized but not yet configured

enumerator HAL_SMBUS_STATE_IDLE

Initialized and a global configuration applied

enumerator HAL_SMBUS_STATE_TX

Data transmission process is ongoing

enumerator HAL_SMBUS_STATE_RX

Data reception process is ongoing

enumerator HAL_SMBUS_STATE_LISTEN

Address listen mode is ongoing

enumerator HAL_SMBUS_STATE_TX_LISTEN

Address listen mode and data transmission process is ongoing

enumerator HAL_SMBUS_STATE_RX_LISTEN

Address listen mode and data reception process is ongoing

enumerator HAL_SMBUS_STATE_ABORT

Abort user request is ongoing

enum hal_smbus_xfer_opt_t

SMBUS Transfer Options.

Values:

enumerator HAL_SMBUS_XFER_FIRST_FRAME

First Frame Transfer Option Enable I2C Software end mode with no HW PEC comparison.

enumerator HAL_SMBUS_XFER_NEXT_FRAME

Next Frame Transfer Option

enumerator HAL_SMBUS_XFER_FIRST_AND_LAST_FRAME_NO_PEC

First and Last Frame Transfer Option without PEC 0x02000000 Automatic end mode (master mode) Enable I2C Automatic end mode with no HW PEC comparison.

enumerator HAL_SMBUS_XFER_LAST_FRAME_NO_PEC

Last Frame Transfer Option without PEC 0x02000000 Automatic end mode (master mode) Enable I2C Automatic end mode with no HW PEC comparison.

enumerator HAL_SMBUS_XFER_FIRST_FRAME_WITH_PEC

First Frame Transfer Option with PEC

enumerator HAL_SMBUS_XFER_FIRST_AND_LAST_FRAME_WITH_PEC

First and Last Frame Transfer Option with PEC

enumerator HAL_SMBUS_XFER_LAST_FRAME_WITH_PEC

Last Frame Transfer Option with PEC

enumerator HAL_SMBUS_XFER_OTHER_FRAME_NO_PEC

Other Frame Transfer Option without PEC with restart at each frame

enumerator HAL_SMBUS_XFER_OTHER_FRAME_WITH_PEC

Other Frame Transfer Option with PEC and restart at each frame

enumerator HAL_SMBUS_XFER_OTHER_AND_LAST_FRAME_NO_PEC

Other and last Frame Transfer Option without PEC ended with stop condition

enumerator HAL_SMBUS_XFER_OTHER_AND_LAST_FRAME_WITH_PEC

Other and last Frame Transfer Option without PEC ended with stop condition

enum hal_smbus_slave_xfer_direction_t

SMBUS slave transfer direction master point of view.

Values:

enumerator HAL_SMBUS_SLAVE_DIRECTION_TRANSMIT

Write transfer request by master, slave enters receiver mode. Transmit

enumerator HAL_SMBUS_SLAVE_DIRECTION_RECEIVE

0x00010000 Transfer direction (slave mode) Read transfer request by master, slave enters transmitter mode. Receive

enum hal_smbus_analog_filter_status_t

SMBUS Analog Filter Status.

Values:

enumerator HAL_SMBUS_ANALOG_FILTER_DISABLED

Analog Filter is disabled

enumerator HAL_SMBUS_ANALOG_FILTER_ENABLED

Analog Filter is enabled

enum hal_smbus_own_addr2_status_t

SMBUS Own Address2 Status.

Values:

enumerator HAL_SMBUS_OWN_ADDR2_DISABLED

SMBUS Own Address2 is disabled

enumerator HAL_SMBUS_OWN_ADDR2_ENABLED

SMBUS Own Address2 is enabled

enum hal_smbus_own_addr2_mask_t

SMBUS Own Address2 Masks.

Values:

enumerator HAL_SMBUS_OWN_ADDR2_NOMASK

No mask Own Address2 No mask. SMBUS Own Address2 No Mask

enumerator HAL_SMBUS_OWN_ADDR2_MASK01

0x00000100 OA2[1] is masked, Only OA2[7:2] are compared Only Address2 bits[7:2] are compared. SMBUS Own Address2 Mask 01

enumerator HAL_SMBUS_OWN_ADDR2_MASK02

0x00000200 OA2[2:1] is masked, Only OA2[7:3] are compared Only Address2 bits[7:3] are compared. SMBUS Own Address2 Mask 02

enumerator HAL_SMBUS_OWN_ADDR2_MASK03

0x00000300 OA2[3:1] is masked, Only OA2[7:4] are compared Only Address2 bits[7:4] are compared. SMBUS Own Address2 Mask 03

enumerator HAL_SMBUS_OWN_ADDR2_MASK04

0x00000400 OA2[4:1] is masked, Only OA2[7:5] are compared Only Address2 bits[7:5] are compared. SMBUS Own Address2 Mask 04

enumerator HAL_SMBUS_OWN_ADDR2_MASK05

0x00000500 OA2[5:1] is masked, Only OA2[7:6] are compared Only Address2 bits[7:6] are compared. SMBUS Own Address2 Mask 05

enumerator HAL_SMBUS_OWN_ADDR2_MASK06

0x00000600 OA2[6:1] is masked, Only OA2[7] are compared Only Address2 bits[7] are compared. SMBUS Own Address2 Mask 06

enumerator HAL_SMBUS_OWN_ADDR2_MASK07

0x00000700 OA2[7:1] is masked, No comparison is done No comparison is done. All Address2 are acknowledged. SMBUS Own Address2 Mask 07

enum hal_smbus_slave_ack_general_call_status_t

SMBUS Slave Acknowledge General Call Status.

Values:

enumerator HAL_SMBUS_SLAVE_ACK_GENERAL_CALL_DISABLED

Slave Acknowledge General Call is disabled

enumerator HAL_SMBUS_SLAVE_ACK_GENERAL_CALL_ENABLED

Slave Acknowledge General Call is enabled

enum hal_smbus_pec_status_t

SMBUS Packet Error Check Status.

Values:

enumerator HAL_SMBUS_PEC_DISABLED

SMBUS packet error check is disabled

enumerator HAL_SMBUS_PEC_ENABLED

SMBUS packet error check is enabled

enum hal_smbus_alert_status_t

SMBUS AlertIT Status.

Values:

enumerator HAL_SMBUS_ALERT_DISABLED

SMBUS Alert IT is disabled

enumerator HAL_SMBUS_ALERT_ENABLED

SMBUS Alert IT is enabled

enum hal_smbus_mode_t

SMBUS functional mode.

Values:

enumerator HAL_SMBUS_PERIPHERAL_MODE_HOST

0x00100000 SMBus host address enable SMBus Host address acknowledge SMBUS mode host

enumerator HAL_SMBUS_PERIPHERAL_MODE_SLAVE

SMBus Slave default mode (Default address not acknowledge) SMBUS mode slave

enumerator HAL_SMBUS_PERIPHERAL_MODE_SLAVE_ARP

0x00200000 SMBus device default address enable SMBus Slave Default address acknowledge SMBUS mode slave ARP

enum hal_smbus_slave_wake_up_status_t

SMBUS Slave Wake Up Status.

Values:

enumerator HAL_SMBUS_SLAVE_WAKE_UP_DISABLED

Slave Wake Up is disabled

enumerator HAL_SMBUS_SLAVE_WAKE_UP_ENABLED

Slave Wake Up is enabled

enum hal_smbus_fast_mode_plus_status_t

SMBUS Fast Mode plus Status.

Values:

enumerator HAL_SMBUS_FAST_MODE_PLUS_DISABLED

Fast mode plus disabled

enumerator HAL_SMBUS_FAST_MODE_PLUS_ENABLED

Fast mode plus enabled

enum hal_smbus_timeout_t

HAL SMBUS Timeout Status.

Values:

enumerator HAL_SMBUS_TIMEOUT_NONE

No Timeout

enumerator HAL_SMBUS_TIMEOUT_A

0x00008000 Clock timeout enable timeout_a enable bit Timeout A Selected

enumerator HAL_SMBUS_TIMEOUT_B

0x80000000 Extended clock timeout enable timeout_b (extended clock) enable bit Timeout B Selected

enumerator HAL_SMBUS_TIMEOUT_ALL

timeout_a and timeout_b (extended clock) enable bits Timeout A and B Selected

enum hal_smbus_timeout_a_mode_t

HAL SMBUS Timeout A mode.

Values:

enumerator HAL_SMBUS_TIMEOUTA_MODE_SCL_LOW

timeout_a is used to detect SCL low level timeout. Timeout increase on SCL low

enumerator HAL_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH

0x00001000 Idle clock timeout detection timeout_a is used to detect both SCL and SDA high level timeout. Timeout increase on SCL/SDA High

struct hal_smbus_handle_s
#include <stm32c5xx_hal_smbus.h>

SMBUS handle Structure definition.

Public Members

hal_smbus_t instance

SMBUS registers base address

volatile hal_smbus_state_t global_state

Current state

uint32_t previous_state

Previous state

uint8_t * p_buf_rx

Transfer buffer rx

const uint8_t * p_buf_tx

Transfer buffer tx

uint32_t xfer_size

Transfer size in bytes

volatile uint32_t xfer_count

Transfer counter in bytes

volatile hal_smbus_xfer_opt_t xfer_opt

Transfer options

hal_status_t ( * xfer_isr ) ( hal_smbus_handle_t * hsmbus , uint32_t it_flags , uint32_t it_sources )

Transfer IRQ handler function pointer

volatile uint32_t last_error_codes

Errors limited to the last process. This parameter can be a combination of SMBUS Error Codes

const void * p_user_data

User Data Pointer

hal_os_semaphore_t semaphore

SMBUS OS semaphore

hal_smbus_cb_t p_master_tx_cplt_cb

SMBUS Master Tx Completed callback

hal_smbus_cb_t p_master_rx_cplt_cb

SMBUS Master Rx Completed callback

hal_smbus_cb_t p_slave_tx_cplt_cb

SMBUS Slave Tx Completed callback

hal_smbus_cb_t p_slave_rx_cplt_cb

SMBUS Slave Rx Completed callback

hal_smbus_cb_t p_slave_listen_cplt_cb

SMBUS Slave Listen complete callback

hal_smbus_slave_addr_cb_t p_slave_addr_cb

SMBUS Slave Address Match callback

hal_smbus_cb_t p_abort_cplt_cb

SMBUS Abort callback

hal_smbus_cb_t p_error_cb

SMBUS Error callback

struct hal_smbus_config_t
#include <stm32c5xx_hal_smbus.h>

SMBUS global configuration structure definition.

Public Members

uint32_t timing

SMBUS_TIMINGR register value calculated by referring to SMBUS initialization section in the Reference Manual. This timing is directly calculated by CubeMX2. Bit 24 to 27 are reserved. A calculation helper is also available in the package. See stm32_utils_i2c.c/.h

uint32_t own_address1

First device own address. The device 7-bit address value must be shifted left by 1 bit. In other words, an 8-bit value is required and the bit 0 is not considered.

hal_smbus_mode_t device_mode

Master, slave, or slave ARP mode

struct hal_smbus_timeout_config_t
#include <stm32c5xx_hal_smbus.h>

HAL SMBUS Timeout Config.

Public Members

uint32_t timeout_a

SMBUS Timeout A timeout value

hal_smbus_timeout_a_mode_t timeout_a_mode

SMBUS Timeout A mode

uint32_t timeout_b

SMBUS Timeout B timeout value